package com.rykj.qxj.result;

import java.io.Serializable;

import org.apache.commons.lang.StringEscapeUtils;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.alibaba.fastjson.serializer.ToStringSerializer;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;

/**
 * @Description:定义接口返回的数据包装
 * @date:   2019年3月21日 下午5:00:06
 * @author: wangshunyi
 */
//@JsonIgnoreProperties(value = { "handler" })
public class BaseResponse<T> implements Serializable{

	/**
	 * @Fields serialVersionUID : (用一句话描述这个变量表示什么)
	 */
	private static final long serialVersionUID = -7127117865880917293L;
	/**
	 * 状态码
	 */
	private String code;
	/**
	 * 错误信息
	 */
	private String  message;
	/**
	 * 业务报文
	 */
	private T data;

	public BaseResponse() {
	}

	public BaseResponse(String code) {
		this.code = code;
	}

	public BaseResponse(String code, String messge) {
		this.code = code;
		this.message = messge;
	}

	public BaseResponse(String code, String message, T data) {
		this.code = code;
		this.message = message;
		this.data = data;
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}

	public Object getdata() {
		return this.data;
	}

	public void setData(T data) {
		this.data = data;
	}

	/*
	@Override
	public String toString() {
		return "BaseResponse [code=" + code + ", message=" + message + ", data=" + data + "]";
	}

	public boolean succ() {
		return "0" == this.code;
	}
	public static BaseResponse execute(String code, String message, Object data) {
		BaseResponse r = new BaseResponse(code, message);
		if (data != null)
			r.setdata(data);
		return r;
	}
	public static BaseResponse execute(ErrType type, Object data) {
		return execute(type.getCode(), type.getMessage(), data);
	}

	public static BaseResponse execute(String code, String message) {
		return execute(code, message, null);
	}

	public static BaseResponse execute(ErrType type) {
		return execute(type.getCode(), type.getMessage());
	}

	public static BaseResponse execute(String code) {
		return execute(code, ErrType.getMessage(code));
	}

	public static BaseResponse fail(String code) {
		return execute(code);
	}

	public static BaseResponse fail(String code, String message) {
		return execute(code, message);
	}

	public static BaseResponse fail(ErrType type) {
		return execute(type);
	}

	public static BaseResponse fail(ErrType type, String message) {
		return execute(type.getCode(), message);
	}

	public static BaseResponse success() {
		return execute(ErrType.SUCCESS);
	}

	public static BaseResponse success(String data) {
		return execute(ErrType.SUCCESS, data);
	}

	public static BaseResponse exception(ErrType type) {
		return execute(type);
	}

	public static BaseResponse exception(String code, String message) {
		return execute(code, message);
	}
	public static BaseResponse exception(ErrType type, String message) {
		return execute(type.getCode(), message);
	}*/
}
